#include <iostream>
using namespace std;

class Person
{
public:
  int age;
  Person(int age)
  {
    // this指针指向被调用的成员函数所属的对象
    this->age = age;
    cout << this << endl;
  }

  Person &PersonAddAge(const Person &p)
  {
    this->age += p.age;
    return *this;
  }
};

// 1. 解决名称冲突

void test01()
{
  Person p1(19);
  cout << &p1 << endl;
  cout << p1.age << endl;
}

// 2. 返回对象本身
void test02()
{
  Person p1(10);

  Person p2(10);

  p2.PersonAddAge(p1).PersonAddAge(p1);

  cout << "p2的年龄：" << p2.age << endl;
}

int main(int argc, char const *argv[])
{
  // test01();
  test02();

  return 0;
}